﻿using Microsoft.AspNetCore.Mvc;
using MVC.Models;

namespace MVC.Core
{
    public class NewStudents : ViewComponent
    {
        public NewStudents()
        {
            
        }

        /// <summary>
        /// 获取数据源
        /// </summary>
        /// <param name="num">学生数量从视图传进来</param>
        /// <returns></returns>
        public IViewComponentResult Invoke(int num)
        {
            var users = new List<UserInfo>();
            for (int i = 0; i < num; i++)
            {
                users.Add(new UserInfo { Id = i, Name = num + "学生" });
            }
            return View(users);
        }
    }
}

